<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>登陆</title>
<link href="${ctx}/css/login.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/js/jquery-ui/css/jquery-ui.css" type="text/css" rel="stylesheet" />
<script src="${ctx}/js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="${ctx}/js/jquery-ui/js/jquery-ui-min.js" type="text/javascript"></script>
<script src="${ctx}/js/jquery-ui/js/jquery.bgiframe.js" type="text/javascript"></script>
<script src="${ctx}/js/jquery.validate.min.js" type="text/javascript"></script>
<script src="${ctx}/js/validate.addmethod.js" type="text/javascript"></script>
<script type="text/javascript" src="${ctx }/js/util.js"></script>
<script type="text/javascript">
if (window.top!=window.self) {
    window.top.location=window.location; 
}
</script>
</head>


<body>
<div class="bg">
    <div class="login">权限管理系统</div>
	<form id="login_form" action="${ctx}/admin/login.do" method="post">
	<table width="375" height="100" border="0">
	  <tr>
	    <td class="login_name">用户名：</td>
	    <td><input name="acc.username" id="username" type="text" class="login_input" value="${acc.username}"  tabindex="1"/></td>
	    <td rowspan="3" ><input value="" name="ssss" type="submit" class="bnt_1" tabindex="4"/></td>
	  </tr>
	  <tr>
	    <td class="login_name">密&nbsp;&nbsp;&nbsp;码：</td>
	    <td><input name="acc.password" id="password" type="password" class="login_input" tabindex="2"/></td>
	    </tr>
	  <tr>
	    <td  class="login_name">验证码：</td>
	    <td><input id="safecode" name="safecode" value="" type="text" class="yzm" tabindex="3"/><img id="safecode_img" src="${ctx}/servlet/ImageServlet" height="28px" width="94px" style="cursor: pointer;" class="yzmImg" onclick="reloadVerifyCode();"/>
	    </td>
	  </tr>
	  <tr>
	    <td id="login_error" colspan="2"  style="font-weight: bolder;">
            <br/>
            <noscript><b style="color:red">对不起，你的游览器禁用了JavaScript!无法登录</b></noscript>
    	    <s:actionerror cssStyle="color:red"/>
	    </td>
	  </tr>
	</table>
   </form>
</div>

<div class="footer">建议使用Microsoft Internet Explorer 8.0+ 访问本网站<br/><br/></div>
</body>
<script type="text/javascript">

	// 重载验证码  
	function reloadVerifyCode(){  
	       var timenow = new Date().getTime();                          
	       var safe_code_img =  $("#safecode_img").get(0);
	       safe_code_img.src="${ctx}/servlet/ImageServlet?d=" + timenow;  
	}

$(function() {
	
	if($.browser.msie && parseInt($.browser.version)<7){
		var showtxt = "您正在使用的是IE6.0或更低版本的浏览器，建议您升级IE浏览器。<br/>或者使用谷歌浏览器、火狐浏览器访问本网站，谢谢合作！";
		var html = "<div style='font-size:18px;color:red;line-height:45px;'>"+showtxt+"</div>";
		$(html).dialog({height: 160,width:580,
	      modal:true,draggable:false,closeOnEscape:false,resizable:false
	    });
		$("div.ui-dialog-titlebar").remove();
		$(".ui-widget-overlay").css("opacity","0.7");
	}
	
    $("#login_form").validate({
        ignore: "",  // 开启hidden验证， 1.9版本后默认关闭
        rules: {
            "acc.username": {
            	required: true
            },
            "acc.password": {
                required: true
                //minlength: 6
            }
            //<s:if test='#request.validSafeCode=="on"'>
            ,"safecode": {
                required: true
            }//</s:if>
        },
        messages: {
            "acc.username": "请输入用户名",
            "acc.password": {
                required: "请输入密码",
                minlength: "密码长度至少为3"
            }
        	//<s:if test='#request.validSafeCode=="on"'>
        	,"safecode": {
            	required: "请输入验证码"
            }//</s:if>
        },
        errorPlacement: function (error, element) { //指定错误信息位置
            /*if (element.hasClass("yzm")) {
                error.appendTo($("#login_error"));
            } else {
                error.insertAfter(element);
            }*/
            error.appendTo($("#login_error"));
        },
        submitHandler: function(form) { 
	        var password = $("#password")[0];
	        password.value = hex_md5(password.value); 
	        form.submit(); //不能用$("#id").submit() 会导致死循环
	    }
    });
});
</script>
</html>
